package com.xtianzhuang.www.controller.system;

import java.util.List;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.xtianzhuang.www.annotation.Log;
import com.xtianzhuang.www.annotation.Log.LogType;
import com.xtianzhuang.www.controller.BaseController;
import com.xtianzhuang.www.entity.TdSStatic;
import com.xtianzhuang.www.entity.constants.CodeConstants;
import com.xtianzhuang.www.entity.request.AddDataIdRequest;
import com.xtianzhuang.www.entity.request.AddTypeIdRequest;
import com.xtianzhuang.www.entity.request.DeleteSystemStaticRequest;
import com.xtianzhuang.www.entity.request.QueryStaticListRequest;
import com.xtianzhuang.www.entity.request.base.BaseRequest;
import com.xtianzhuang.www.entity.response.AddDataIdResponse;
import com.xtianzhuang.www.entity.response.AddTypeIdResponse;
import com.xtianzhuang.www.entity.response.DeleteSystemStaticResponse;
import com.xtianzhuang.www.entity.response.QueryStaticListReponse;
import com.xtianzhuang.www.entity.response.SystemTypeIdQueryResponse;
import com.xtianzhuang.www.entity.response.base.BaseResponse;

@Controller
@RequestMapping("/system")
public class SystemController extends BaseController {
	@RequestMapping("/systemParamsQuery")
	public ModelAndView systemParamsQuery(BaseRequest request, BaseResponse response) {
		ModelAndView model = new ModelAndView("/system/system-static");
		List<TdSStatic> list = systemServiceBiz.TypeIdQuery();
		model.addObject("list", list);
		super.executeBase(request, response);
		model.addObject("res", response);
		return model;
	}

	@RequestMapping("/systemStaticQuery")
	@ResponseBody
	public SystemTypeIdQueryResponse systemTypeIdQuery() {
		SystemTypeIdQueryResponse response = new SystemTypeIdQueryResponse();
		List<TdSStatic> list = systemServiceBiz.TypeIdQuery();
		response.setCode(CodeConstants.SUCCESS);
		response.setMessage("查询成功");
		response.setList(list);
		return response;
	}


	@RequestMapping("/ajaxQueryStaticList")
	@ResponseBody
	@Log(type = LogType.SYSTEM)
	public QueryStaticListReponse queryStaticList(QueryStaticListRequest request) {
		QueryStaticListReponse response = new QueryStaticListReponse();
		long count = systemServiceBiz.queryStaticCountByTypeId(request.getTypeId());
		List<TdSStatic> list = systemServiceBiz.queryStaticByTypeId(request.getTypeId());
		response.setCode(CodeConstants.SUCCESS);
		response.setMessage("查询成功");
		response.setData(list);
		response.setTotal(count);
		return response;
	}

	@RequestMapping("/ajaxDeleteSystemStatic")
	@ResponseBody
	@Log(type = LogType.SYSTEM)
	public DeleteSystemStaticResponse deleteSystemStatic(DeleteSystemStaticRequest request) {
		DeleteSystemStaticResponse response = new DeleteSystemStaticResponse();
		systemServiceBiz.deleteSystemStatic(request);
		response.setCode(CodeConstants.SUCCESS);
		response.setMessage("删除成功");
		return response;
	}

	@RequestMapping("/ajaxAddTypeId")
	@ResponseBody
	@Log(type = LogType.SYSTEM)
	public AddTypeIdResponse addTypeId(AddTypeIdRequest request) {
		AddTypeIdResponse response = new AddTypeIdResponse();
		systemServiceBiz.addTypeId(request);
		response.setCode(CodeConstants.SUCCESS);
		response.setMessage("添加成功");
		return response;
	}



	@RequestMapping("/ajaxAddDataId")
	@ResponseBody
	@Log(type = LogType.SYSTEM)
	public AddDataIdResponse addDataId(AddDataIdRequest request) {
		AddDataIdResponse response = new AddDataIdResponse();
		systemServiceBiz.addDataId(request);
		response.setCode(CodeConstants.SUCCESS);
		response.setMessage("添加成功");
		return response;
	}


}
